﻿using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Framework.Reflection;
using Pixysoft.Weblications.Sango.Protocol.section;
using Pixysoft.Weblications.Sango.Environment;
using Pixysoft.Weblications.Sango.Protocol;

namespace Pixysoft.Weblications.Sango.Command.section
{
    partial class SangoSectionHandler
    {
        public section_list section_list(double geox, double geoy)
        {
            section_list response = ReflectionManager.CreatePojo<section_list>();

            Entities.Sys_Section upper = SysSectionHelper.searchUpperSection(geox, geoy);
            Entities.Sys_Section lower = SysSectionHelper.searchLowerSection(geox, geoy);

            Entities.Sys_Section left = SysSectionHelper.searchLeftSection(geox, geoy);
            Entities.Sys_Section right = SysSectionHelper.searchRightSection(geox, geoy);

            response.upper = UsrSectionFacade.ToSectionArea(upper);
            response.lower = UsrSectionFacade.ToSectionArea(lower);
            response.left = UsrSectionFacade.ToSectionArea(left);
            response.right = UsrSectionFacade.ToSectionArea(right);


            Entities.Sys_Section section = SysSectionHelper.trySearchSectionByGeolocation(geox, geoy);
            response.percentx = (geox - section.Mingeolocationx) / (section.Maxgeolocationx - section.Mingeolocationx);
            response.percenty = (geoy - section.Mingeolocationy) / (section.Maxgeolocationy - section.Mingeolocationy);

            response.Succeed = true;
            return response;
        }
    }

    public interface section_list : ISangoResponse
    {
        double percentx { get;set;}
        double percenty { get;set;}

        section_area upper { get;set;}
        section_area lower { get;set;}
        section_area left { get;set;}
        section_area right { get;set;}
    }
}
